<template>
  <div class="container" ref="mainCon">
    <div
      style="position: relative"
      v-if="path != 'esSpecialAccountList' && !isHefeng"
    >
      <topTitle
        titleText="工资专户"
        :back="back"
        @gobackTriser="goback"
      ></topTitle>
      <div class="fr">
        <button
          type="button"
          class="editBut commonBut saveBtn funComBut"
          @click="toUpdate"
          v-show="
            isShowUpdate &&
            !heFengProject &&
            (loginType === 'QY' || loginType === 'XM')
          "
        >
          <i class="icon iconfont iconbianji"></i> 修改
        </button>
      </div>
    </div>
    <div v-else>
      <el-tooltip
        class="item"
        effect="dark"
        :content="projectName"
        placement="top-start"
      >
        <topTitle
          :titleText="
            projectName.length > 30
              ? projectName.substring(0, 30) + '...'
              : projectName + ' - 交易流水'
          "
          :back="back"
          @gobackTriser="goback"
        ></topTitle>
      </el-tooltip>
    </div>
    <!-- <div class="mainCon"> -->
    <salarySpecialAccount
      ref="salarySpecialAccount"
      :projectId="projectId"
    ></salarySpecialAccount>
    <!-- </div> -->
  </div>
</template>

<script>
import salarySpecialAccount from '@/components/specialAccount/salarySpecialAccount'

export default {
  name: 'companyAccountDetail',
  components: {
    salarySpecialAccount,
  },
  data() {
    return {
      isShowBtn: true,
      projectId: '',
      projectName: '',
      accountCode: '',
      bankId: '',
      isShowUpdate: '',
      path: '', //跳转过来的路径
      heFengProject: '',
      loginType: '',
      back: true,
    }
  },
  created() {
    this.projectId = this.$route.query.projectId
    this.projectName = this.$route.query.projectName
    // this.heFengProject = this.$route.query.heFengProject;
    this.path = this.$route.query.path
    this.isShowUpdate =
      this.$store.state.buttonLimitsArr.indexOf('accountList:update') > -1
    this.loginType = localStorage.getItem('loginType')
    if (
      this.$route.query.heFengProject == 'false' ||
      this.$route.query.heFengProject == false
    ) {
      this.heFengProject = false
    } else {
      this.heFengProject = true
    }
  },
  computed: {
    isHefeng() {
      return this.$store.state.isHefeng
    },
  },
  mounted() {},
  methods: {
    goback() {
      //从项目详情页面-管理专户跳转过来的
      if (this.path === 'projectListQY') {
        this.$router.push('/home/companyProjectManage/projectDetailQY')
        this.$store.commit('CHANGE_SLIDER_NAME', {
          oldUrl: '/home/companyProjectManage/projectDetailQY',
          newUrl: this.$router.currentRoute.fullPath,
        })
      }
      //从专户列表跳转过来的
      if (this.path === 'specialAccountList') {
        this.$router.push('/home/specialAccount/specialAccountList')
        this.$store.commit('GOBACK_NAME', {
          oldUrl: '/home/specialAccount/specialAccountList',
          newUrl: this.$router.currentRoute.fullPath,
        })
      }
      //从滁州专户列表跳转过来的
      if (this.path === 'specialAccount') {
        this.$router.push('/home/separateAccountManagement/specialAccount')
        this.$store.commit('GOBACK_NAME', {
          oldUrl: '/home/separateAccountManagement/specialAccount',
          newUrl: this.$router.currentRoute.fullPath,
        })
      }
      if (this.path === 'esSpecialAccountList') {
        this.$router.push('/home/enShiCustomRequirements/esSpecialAccountList')
        this.$store.commit('GOBACK_NAME', {
          oldUrl: '/home/enShiCustomRequirements/esSpecialAccountList',
          newUrl: this.$router.currentRoute.fullPath,
        })
      }
      // 鹤峰流水回传
      if (this.path === 'hfManualPostback') {
        this.$router.push('/home/enShiCustomRequirements/hfManualPostback')
        this.$store.commit('GOBACK_NAME', {
          oldUrl: '/home/enShiCustomRequirements/hfManualPostback',
          newUrl: this.$router.currentRoute.fullPath,
        })
      }
    },
    //若调用子组件里b方法
    toUpdate() {
      this.$refs.salarySpecialAccount.updateAccount()
    },
  },
}
</script>

<style scoped lang="less">
.container {
  .topContent {
    background: #e4ebf1;
    height: 67px;
    line-height: 40px;
    padding: 15px 24px;
    .titleTop {
      font: bold 18px Microsoft YaHei;
      color: #333333;
    }
    .alignRight {
      text-align: right;
    }
    .createSalaryBut {
      background: #009588;
      border: 1px solid #009588;
      padding: 9px 23px;
      &:hover {
        opacity: 0.8;
      }
    }
  }
  .mainCon {
    top: 198px;
  }
  .editBut {
    position: absolute;
    top: 7px;
    right: 24px;
    height: 36px;
    border: 0;
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
    background: #009588;
    padding: 0 10px;
    cursor: pointer;
    &:hover {
      background-color: #009588;
      border-color: #009588;
      color: #fff;
      opacity: 0.8;
    }
  }
}
</style>
